package cn.edu.tju.se.auth.service;

import cn.edu.tju.se.auth.enity.Administrator;
import cn.edu.tju.se.auth.repository.AdminRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminService {

    @Autowired
    private AdminRepository adminRepository;

    public void addAdmin(Administrator administrator){
        adminRepository.save(administrator);
    }

    public void deleteAdmin(Administrator administrator){
        adminRepository.delete(administrator);
    }

    public List<?> getAllAdmin(){
        return adminRepository.findAll();
    }

    public List<?> getAdmin(String adminname){
        return adminRepository.findByadminname(adminname);
    }
}
